package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.medicalmodel.CarouselData;
import com.quasar.hpatient.model.medicalmodel.CollectionListData;
import com.quasar.hpatient.model.medicalmodel.ConsultationBean;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnConsultationListener;

/**
 * author : 许建宏
 * Date: 2017/10/23 0023
 * View:咨询列表
 */

public class RecommendListPresenter {

    private RequestModel requestModel;
    private OnConsultationListener onConsultationListener;

    public RecommendListPresenter(OnConsultationListener onConsultationListener) {
        this.requestModel = new RequestModel();
        this.onConsultationListener = onConsultationListener;
    }

    public void RecommendList(final String page) {

        requestModel.PostRecommendList(page, new AnotherResultListener<AnotherResult<ConsultationBean>>() {
            @Override
            public void onSuccess(AnotherResult<ConsultationBean> data) {
                onConsultationListener.onConsultationListSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onConsultationListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onConsultationListener.onConsultationRefreshUI();
            }
        });
    }

    //咨询轮播
    public void GetCarouselInformationsData(String page) {

        requestModel.GetCarouselInformationsData(page, new AnotherResultListener<AnotherResult<CarouselData>>() {
            @Override
            public void onSuccess(AnotherResult<CarouselData> data) {
                onConsultationListener.onCarouselSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onConsultationListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onConsultationListener.onConsultationRefreshUI();
            }
        });
    }

    //我的收藏列表
    public void MyRecommendListData(String page) {

        requestModel.PostCollection(page,new AnotherResultListener<AnotherResult<CollectionListData>>() {
            @Override
            public void onSuccess(AnotherResult<CollectionListData> data) {
                onConsultationListener.onMyConsultationListSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onConsultationListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onConsultationListener.onConsultationRefreshUI();
            }
        });
    }

    //判断是否已经收藏
    public void GetCollectionInfoExistData(String recordId){

        requestModel.GetCollectionInfoExistData(recordId, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onConsultationListener.onNottoCollectSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onConsultationListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onConsultationListener.onConsultationRefreshUI();
            }
        });
    }

    //收藏咨询按钮
    public void UpdateMedicalInformationCollectData(String recordId){

        requestModel.UpdateMedicalInformationCollectData(recordId, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onConsultationListener.onButtonCollectionSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onConsultationListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onConsultationListener.onConsultationRefreshUI();
            }
        });
    }

}
